package mac.types.interfacePedlInstr;
import java.util.*;

public class ExecPoint {
  static final int NO_MESSAGE = 0;
  static final int FINAL_PARAM = 1;
  static final int INITIAL_PARAM = 2;
  static final int BOTH = 3;

  protected String name;
  protected boolean prog;
  protected boolean start;
  protected int end;
  protected Variable parent;

  public ExecPoint(String n) { 
    name = n; 
    prog = false;
    start = false;
    end = NO_MESSAGE;
    parent = new Variable(n.substring(0, n.lastIndexOf('.')));
  }
  public ExecPoint(String n, boolean p) {    
    name = n; 
    prog = p;
    start = false;
    end = NO_MESSAGE;
    parent = new Variable(n.substring(0, n.lastIndexOf('.')));
  }
  public ExecPoint(String n, boolean p, boolean s, int e) {
    name = n; 
    prog = p;
    start = s;
    end = e;
    parent = new Variable(n.substring(0, n.lastIndexOf('.')));
  }

  public String getMethodName() {
    return name.substring(name.lastIndexOf('.')+1, name.indexOf('('));
  }
  public boolean isProgram() { return prog; }
  public boolean sendAtStart() { return start; }
  public int getEnd() { return end; }
  public Variable getParent() { return parent; }
  public String[] getParameterTypes() {
    String[] types;
    StringTokenizer s;

    s = new StringTokenizer(name.substring(name.indexOf('(')+1, name.indexOf(')'
)), ",");
    types = new String[s.countTokens()];
    for( int i = 0; s.hasMoreTokens(); i++ )
      types[i] = s.nextToken();
    return types;
  }
  public void setProg(boolean p) { prog = p; }
  public void setStart(boolean s) { start = s; }
  public void setEnd(int e) { end = e; }
}
